// 网站设置
<template>
  <div class="">

    <el-row class="bread-nav">
      <ul class="bread-nav-title">
        <span>系统</span>
      </ul>
    </el-row>
<div class="content">
    <table class="contentTable">
      <tr>
        <td class="contentTable-left">
          公司名
        </td>
        <td colspan="3">
          <input type="text" v-model="form.site_name">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          导航码
        </td>
        <td colspan="3">
          <input type="text" v-model="form.nav_code" class="aloneText">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          （每天）信用恢复
        </td>
        <td colspan="3">
          <input type="text" class="aloneText" v-model="form.credit_amount_restore_time">
          <button @click="restoreCredit">恢复信用</button>
          <button>校对当天输赢</button>
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          现金操作
        </td>
        <td colspan="3">
          <el-radio v-model="form.cash_operation" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.cash_operation" :label="'1'">开放</el-radio>
          <el-radio v-model="form.cash_operation" :label="'2'">开放-禁止跨级操作</el-radio>
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          占成修改
        </td>
        <td colspan="3">
          <el-radio v-model="form.share_modify" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.share_modify" :label="'1'">开放</el-radio>
          <el-radio v-model="form.share_modify" :label="'2'">开盘限制</el-radio>
          <el-radio v-model="form.share_modify" :label="'3'">限制时段--每天</el-radio>
          <input type="text" v-model="form.share_modify_limit_begin">~
          <input type="text" v-model="form.share_modify_limit_end">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          退水补货
        </td>
        <td colspan="3">
          <el-radio v-model="form.comm_padding" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.comm_padding" :label="'1'">开放</el-radio>
          <el-radio v-model="form.comm_padding" :label="'2'">开盘限制</el-radio>
          <el-radio v-model="form.comm_padding" :label="'3'">限制时段--每天</el-radio>
          <input type="text" v-model="form.comm_padding_limit_begin">~
          <input type="text" v-model="form.comm_padding_limit_end">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          报表查询
        </td>
        <td colspan="3">
          <el-radio v-model="form.report_search" :labek="'0'">关闭</el-radio>
          <el-radio v-model="form.report_search" :labek="'1'">开放</el-radio>
          <el-radio v-model="form.report_search" :labek="'2'">限制时段--每天</el-radio>
          <input type="text" v-model="form.report_search_limit_begin">~
          <input type="text" v-model="form.report_search_limit_end">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          类别选择
        </td>
        <td colspan="3">
          <el-radio v-model="form.lottery_select" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.lottery_select" :label="'1'">开放</el-radio>
          <el-radio v-model="form.lottery_select" :label="'2'">维护时段--每天</el-radio>
          <input type="text" v-model="form.lottery_select_limit_begin">~
          <input type="text" v-model="form.lottery_select_limit_end">
          <button @click="dialogTableVisible = !dialogTableVisible">开放彩种</button>
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          最低投注限额
        </td>
        <td>
          <input type="text" class="aloneText" v-model="form.min_order_amount">
          <span>公司限额（临时）:</span>
          <el-radio v-model="form.tmp_min_limit" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.tmp_min_limit" :label="'1'">开放</el-radio>
        </td>
        <td class="contentTable-left">
          结余小数
        </td>
        <td>
          <input type="text" class="aloneText" v-model="form.deal_decimals">
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          系统维护
        </td>
        <td colspan="3">
          <el-radio v-model="form.system_status" :label="'0'">维护</el-radio>
          <el-radio v-model="form.system_status" :label="'1'">运营</el-radio>
          <el-radio v-model="form.system_status" :label="'2'">限制时段--每天</el-radio>
          <input type="text" v-model="form.system_maintain_begin">~
          <input type="text" v-model="form.system_maintain_end">
        </td>
      </tr>
      <tr>
      <td class="contentTable-left">
      报表删除
      </td>
        <td colspan="3">
          <el-radio  v-model="form.report_delete" :label="'0'">关闭</el-radio>
          <el-radio  v-model="form.report_delete" :label="'1'">开放</el-radio>
          <span>报表保留：</span>
          <input type="text" v-model="form.report_remain_days">
          <span>天</span>
        </td>
      </tr>
      <tr>
        <td class="contentTable-left">
          用户删除
        </td>
        <td colspan="3">
          <el-radio v-model="form.user_delete" :label="'0'">关闭</el-radio>
          <el-radio v-model="form.user_delete" :label="'1'">维护</el-radio>
          <button>解锁所有用户</button>
          <span>重置密码时间：{{form.reset_pwd_days}}天</span>
          <span>密码错误锁定次数：{{form.login_error_lock_times}}次</span>
          <span>锁定时间：{{form.lock_sec}}秒</span>
          <span>登录间隔：{{form.login_interval}}秒</span>
        </td>
      </tr>
    </table>

    <el-row class="baseOdd-bottom">
      <button @click="subfrom()">确认</button>
      <button @click="onReset">取消</button>
    </el-row>

  <el-dialog title="彩票类别开放" :visible.sync="dialogTableVisible">
    <div class="dialogDiv">
      <table>
        <thead>
        <tr>
          <th>彩种</th>
          <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(item,index) in form.games">
          <td>
            {{item}}
          </td>
          <td>
            <el-radio v-model="form.open_games[index]" :label="1">开放</el-radio>
            <el-radio v-model="form.open_games[index]" :label="0">关停</el-radio>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
      <ul class="dialogUl">
        <button>确认</button>
        <button @click="dialogTableVisible=!dialogTableVisible">取消</button>
      </ul>
    </el-dialog>
  </div>
  </div>
</template>

<script>
// import { user as userMap } from '@/utils/map' // 参数映射
import { Message } from 'element-ui'
export default {
  name: 'index',
  data() {
    return {
      form: {},
      dialogTableVisible: false, // 弹窗
    }
  },
  computed: {},
  created() {
    this.getSetting()
  },
  methods: {
    // 恢复信用
    restoreCredit() {
      if (window.confirm('你确定要提交修改吗？')) {
        this.$store.dispatch('RestoreCredit')
          .then(response => {
            this.$message({
              message: response.message,
              type: 'success',
            })
          })
        return true
      } else {
        return false
      }
    },
    // 查询设置
    getSetting() {
      this.$store.dispatch('SystemSettings', {}).then(response => {
        if (response) {
          this.form = response
        }
        console.log('0000000000', this.form)
        // console.log(this.setting)
      })
    },
    // 保存系统设置
    subfrom() {
      if (window.confirm('你确定要提交修改吗？')) {
        console.log(this.form)
        this.$store.dispatch('UpdateSystemSettings', { SystemSettingsUpdateForm: this.form })
          .then(response => {
            Message.success(response.message)
          })
        return true
      } else {
        return false
      }
    },
    onSubmit() {
      // this.$refs.form.validate(valid => {
      // if (valid) {
      // 处理input
      // this.form.site_name = this.form.site_name.trim()
      // this.form.site_maintain_message = this.form.site_maintain_message.trim()
      // this.loading = true

      this.$store
        .dispatch('SetSiteConfigs', { params: this.form })
        .then(response => {
          this.loading = false
          if (response === true) {
            this.$message({
              message: '修改成功!',
              type: 'success',
            })
          } else {
            this.$message({
              message: '修改失败!',
              type: 'error',
            })
          }
          // 重载数据
          this.getSetting()
        })
      // }
      // else {
      //   return false
      // }
      // })
    },
    // 重置信息
    onReset() {
      // 返回列表
      this.getSetting()
    },
  },
}
</script>

<style scoped>
  .bread-nav{
    height:30px;
    font-size: 13px;
    line-height: 30px;
    background: #ECEFF2;
    border-bottom: 1px solid #d0dff2;
    padding: 0 0 0 10px;
    overflow: hidden;
  }
  .bread-nav-title{
    color:#386399;
    font-weight: bold;
    float: left;
    background: url("../../../../static/agent/img/tb.png") no-repeat left center;
    padding-left: 20px;
  }

  .content{
    padding: 10px;
  }
.contentTable{
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}
.contentTable td{
  height: 25px;
  color: #131950;
  line-height: 25px;
  font-size:14px;
  border: 1px solid #B9C2CB;
  padding: 5px;
}
  .contentTable td input[type='text']{
    width:60px;
  }
  .contentTable td .el-radio{
    margin:0 5px;
  }
  .contentTable td button{
    margin:0 5px;
  }
  .subTr{
    float: right;
  }
  .subTr td{
    border:0;
    border-left: 1px solid #B9C2CB;
    padding: 0;
    margin: 0;
  }
  .aloneText{
    margin-right:5px;
  }
.contentTable-left{
  text-align: right;
  color: #344b50;
  background: #f2f2f2;
}
.baseOdd-bottom{
  text-align: center;
  margin-top: 20px;
}
.baseOdd-bottom button{
  width: 86px;
  height: 31px;
  line-height: 26px;
  color: #eeeeee;
  border: 0px;
  background-color: #487BD1;
  border-radius: 5px;
}
.baseOdd-bottom button:hover{
  background-color: #7bb1d0;
  color:#fff100;
}

  .dialogDiv{
    max-height:300px;
    overflow-y: scroll;
  }
  .dialogDiv table{
    width: 100%;
  }
  .dialogDiv table th{
    box-shadow: inset 0px -14px 19px 2px #CAE8F6;
    height: 25px;
    text-align: center;
    color: #131950;
    font-weight: bold;
    line-height: 25px;
    font-size:14px;
    padding-left: 10px;
    padding-right: 10px;
    border: 1px solid #B9C2CB;
    margin: 0;
  }
  .dialogDiv table td{
    height: 25px;
    text-align: center;
    color: #131950;
    line-height: 25px;
    font-size:14px;
    padding: 5px;
    border: 1px solid #B9C2CB;
  }
  .dialogUl{
    text-align: right;
    margin-top: 20px;
  }
  .dialogUl button{
    width: 86px;
    height: 31px;
    line-height: 26px;
    color: #eeeeee;
    border: 0px;
    background-color: #487BD1;
    border-radius: 5px;
  }
  .dialogUl button:hover{
    background-color: #7bb1d0;
    color:#fff100;
  }
</style>

